package com.neu.envprotection.feedback.controller;

import com.neu.envprotection.common.constant.SystemConfigConsts;
import com.neu.envprotection.common.resp.PageRespDto;
import com.neu.envprotection.common.resp.RestResp;
import com.neu.envprotection.feedback.dto.req.AssignFeedbackReqDto;
import com.neu.envprotection.feedback.dto.req.GetAirQualityReqDto;
import com.neu.envprotection.feedback.dto.req.GetFeedBackReqDto;

import com.neu.envprotection.feedback.dto.resp.*;
import com.neu.envprotection.feedback.service.FeedBackService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/feedback")
@RequiredArgsConstructor
@SecurityRequirement(name = SystemConfigConsts.HTTP_AUTH_HEADER_NAME)
@Tag(name = "反馈记录接口")
@Slf4j
public class FeedbackController {

    @Autowired
    private FeedBackService feedBackService;

    @PostMapping("/queryFeedback")
    @Operation(summary = "分页条件查询反馈")
    private RestResp<PageRespDto<GetFeedBackRespDto>> queryFeedback(@RequestBody GetFeedBackReqDto condition){
        return feedBackService.queryFeedback(condition);
    }

    @PostMapping("/queryQuality")
    @Operation(summary = "分页条件查询反馈")
    private RestResp<PageRespDto<GetAirQualityRespDto>> queryFeedback(@RequestBody GetAirQualityReqDto condition){
        return feedBackService.queryAirQuality(condition);
    }

    @GetMapping("/getFeedbackDetail/{feedbackId}")
    @Operation(summary = "获得反馈详细信息")
    private RestResp<GetFeedbackDetailRespDto> getFeedbackDetail(@PathVariable Integer feedbackId){
        return feedBackService.getFeedbackDetail(feedbackId);
    }

    @GetMapping("/getAirQualityDetail/{airQualityId}")
    @Operation(summary = "获得反馈详细信息")
    private RestResp<GetAirQualityDetailRespDto> getAirQualityDetail(@PathVariable Integer airQualityId){
        return feedBackService.getAirQualityDetail(airQualityId);
    }

    @PostMapping("/assign")
    @Operation(summary = "为监督信息分配网格员")
    private RestResp<Void> assignFeedback(@RequestBody AssignFeedbackReqDto condition){
        return feedBackService.assignFeedbackReqDto(condition);
    }

    @GetMapping("/getCoverData")
    @Operation(summary = "获得省市覆盖率")
    private RestResp<GetCityCoverRespDto>getCoverData(){
        return feedBackService.getCoverData();
    }

    @GetMapping("/getCountData")
    @Operation(summary = "统计优良")
    private RestResp<GetAQICountRespDto>getCountData(){
        return feedBackService.getCountData();
    }

}
